home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: Character string
- Date: 11 Apr 1996 15:55:25 GMT
- Organization: OpenVision
- Message-ID: <4kja1d$7fm@spanky.pls.ov.com>
- References: <4kil74$8i7@Tandem1.opennet.net.au>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article 8i7@Tandem1.opennet.net.au, george@opennet.net.au (Kenneth H Smith) writes:
- >How do I do a similar statement in C to the Pascal code:
- >
- >If Ch IN ['a','A'] THEN
- >
- >I want to execute a piece of code when a particular character is entered
- >from the keyboard.
- >
- >I know I can use if (ch=='a') && (ch=='A') but was looking for something
- >a little more ellegant.
- >
- >Thanks,
- >
- >Ken Smith.
- >
-
-
- For small tests (like two characters) you cannot beat the if test. For
- filtering among many characters, the code can be made much more understandable
- using the switch() statement. switch() allows you to identify various
- responses to input values on a case by case basis. See your local C book.
-
- Fletcher.Glenn@ov.com
-
-
-